package cn.kk.communication.controller;
/*
 *@author KK on 2022.11.19 11:45
 */

import cn.dsna.util.images.ValidateCode;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/verificationCodeServlet")
public class verificationCodeServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int width = 150;
        int height = 30;
        int codeCount = 4;
        int lineCount = 20;
        ValidateCode validateCode = new ValidateCode(width,height,codeCount,lineCount);
        String code = validateCode.getCode();
        System.out.println(code);
        request.getSession().setAttribute("code",code);
        validateCode.write(response.getOutputStream());
    }
}
